import request from '@/utils/request';
import { AxiosPromise } from 'axios';

/**
 * 查询列表
 * @param query
 * @returns {*}
 */

export const list = (query?: PageQuery): AxiosPromise<[]> => {
  return request({
    url: '/biz-vendor/vendorSettlement/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询详细
 * @param id
 */
export const get = (id: string | number): AxiosPromise<{}> => {
  return request({
    url: '/biz-vendor/vendorSettlement/' + id,
    method: 'get'
  });
};

/**
 * 手动结算
 * @param data
 */
export const vendorSettlement = (data: {}) => {
  return request({
    url: '/biz-vendor/vendorSettlement',
    method: 'post',
    data: data
  });
};

/**
 * 查询最近的上一次结算
 * @param data
 */
export const vendorLastSettlement = (vendorId: string | number) => {
  return request({
    url: '/biz-vendor/vendorSettlement/last/' + vendorId,
    method: 'get'
  });
};

/**
 * 重新结算
 * @param data
 */
export const redo = (data: {}) => {
  return request({
    url: '/biz-vendor/vendorSettlement/redo',
    method: 'post',
    data: data
  });
};

/**
 * 作废结算
 * @param data
 */
export const undo = (data: {}) => {
  return request({
    url: '/biz-vendor/vendorSettlement/undo',
    method: 'post',
    data: data
  });
};

/**
 * 新增附件信息
 * @param data
 */
export const upload = (data: {}) => {
  return request({
    url: '/biz-vendor/vendorSettlement/attachment/upload',
    method: 'post',
    data: data
  });
};

/**
 * 删除附件
 * @param ids
 * @returns
 */
export const delAttachment = (ids: {}) => {
  return request({
    url: '/biz-vendor/vendorSettlement/attachment/' + ids,
    method: 'delete'
  });
};

/**
 * 结算调平
 * @param data
 * @returns
 */
export const adjust = (data: {}) => {
  return request({
    url: '/biz-vendor/vendorSettlement/adjust',
    method: 'post',
    data: data
  });
};

/**
 * 删除
 * @param id
 */
export const del = (settlementIds: Array<string | number>) => {
  return request({
    url: '/biz-vendor/vendorSettlement/' + settlementIds,
    method: 'delete'
  });
};

/**
 * 结算列表
 * @param query
 * @returns
 */
export const jsList = (query?: PageQuery): AxiosPromise<[]> => {
  return request({
    url: '/biz-vendor/vendorSettlement/list/items',
    method: 'get',
    params: query
  });
};

/**
 * 调平列表
 * @param query
 * @returns
 */
export const tpList = (query?: PageQuery): AxiosPromise<[]> => {
  return request({
    url: '/biz-vendor/vendorSettlement/list/adjusts',
    method: 'get',
    params: query
  });
};
